/**
 * 2011 Jason
 * 位置基础类
 */

package spotor.client.util;

public class LocationUtils {
	public static final Location createSpotorLocation(
			android.location.Location location) {
		if (location == null) {
			return new Location(null, null, null, null, null);
		}
		String geolat = null;
		if (location.getLatitude() != 0.0) {
			geolat = String.valueOf(location.getLatitude());
		}

		String geolong = null;
		if (location.getLongitude() != 0.0) {
			geolong = String.valueOf(location.getLongitude());
		}

		String geohacc = null;
		if (location.hasAccuracy()) {
			geohacc = String.valueOf(location.getAccuracy());
		}

		String geoalt = null;
		if (location.hasAccuracy()) {
			geoalt = String.valueOf(location.hasAltitude());
		}

		return new Location(geolat, geolong, geohacc, null, geoalt);
	}

	public static class Location {
		String geolat = null;
		String geolong = null;
		String geohacc = null;
		String geovacc = null;
		String geoalt = null;

		public Location() {
		}

		public Location(final String geolat, final String geolong,
				final String geohacc, final String geovacc, final String geoalt) {
			this.geolat = geolat;
			this.geolong = geolong;
			this.geohacc = geohacc;
			this.geovacc = geovacc;
			this.geoalt = geovacc;
		}

		public Location(final String geolat, final String geolong) {
			this(geolat, geolong, null, null, null);
		}
	}
}
